package tasks

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/toolbox"
	"fmt"
)

// 任务
type DeviceHeartBeatCheckTask struct {
}

//设置定时任务
func (this *DeviceHeartBeatCheckTask) InitTask() {
	if beego.AppConfig.String("device_heart_beat_check_cycle") != "false" {
		Cycle := "00 * * * * *"
		if beego.AppConfig.String("device_heart_beat_check_cycle") != "" {
			Cycle = beego.AppConfig.String("device_heart_beat_check_cycle")
		}

		checkDeviceHeartBeat := toolbox.NewTask("checkDeviceHeartBeat", Cycle, this.checkDeviceHeartBeat)
		toolbox.AddTask("checkDeviceHeartBeat", checkDeviceHeartBeat)
	}

	toolbox.StartTask() //开始定时任务
}

//定时任务 - 检查设备心跳
func (this *DeviceHeartBeatCheckTask) checkDeviceHeartBeat() error {
	fmt.Println("设备心跳正常")

	return nil
}